package com.l.web.service.system.extension;

import com.l.web.service.ServiceSupport;
import org.l.qiao.Cluster;
import org.l.qiao.ClusterUtil;
import org.l.qiao.Validate;
import org.apache.log4j.Logger;

public class ExtensionDetailService extends ServiceSupport {

    private static final Logger LOGGER = Logger.getLogger(ExtensionDetailService.class);
    private ExtensionDAO extensionDAO;

    public void setExtensionDAO(ExtensionDAO extensionDAO) {
        this.extensionDAO = extensionDAO;
    }

    public String execute() {
        String id = form.getString("id");
        LOGGER.debug("查看插件：id=" + id);
        if (Validate.check(Validate.OBJECTID, id)) {
            Cluster extension = extensionDAO.findById(id);
            if (extension.isEmpty()) {
                LOGGER.error("所查看的插件不存在");
                error(404);
                return NONE;
            }
            context.put("extension", extension);
            context.put("check", ClusterUtil.getCheck(Extension.class));
            return "detail";
        } else {
            error(404);
            LOGGER.error("非法查看插件信息：id=" + id);
            return NONE;
        }
    }

}
